// Copyright (c) 2020 Presto Labs Pte. Ltd.
// Author: donggu

#pragma once

#include <limits>
#include <tuple>
#include <vector>

#include "coin2/app/executor.pb.h"
#include "coin2/base/config/app_config.h"
#include "coin2/exchange/base/executor/sync_executor.h"

namespace coin2::exchange::base::executor {
namespace impl {

// for merge
struct Entry {
  size_t index;
  int64_t timestamp;
};

inline bool operator<(const Entry& lhs, const Entry& rhs) {
  return std::tie(lhs.timestamp, lhs.index) < std::tie(rhs.timestamp, rhs.index);
}

class ArchiveSyncExecutor : public SyncExecutor {
 public:
  explicit ArchiveSyncExecutor(const coin2::app::ArchiveExecutorConfig& config)
      : SyncExecutor(config.threads()),
        config_(config) {}
  void Run() override;

 private:
  const coin2::app::ArchiveExecutorConfig config_;
};

}  // namespace impl
using impl::ArchiveSyncExecutor;
}  // namespace coin2::exchange::base::executor
